package com.itic.mall.mobile.oss;


import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/*
import com.aliyun.oss.OSSClient;
import com.aliyun.oss.model.Bucket;*/
import com.itic.mall.mobile.base.BaseMobileInterface;


@Controller
@RequestMapping(value="/mobile/alioss")
public class AliOssInterface
     extends BaseMobileInterface {/*
	
	
	*//**
	 * 
	 * @param request
	 * @param response
	 *//*
	@RequestMapping(value = "/test")   
	@ResponseBody 
	public void test(HttpServletRequest request,HttpServletResponse response){  
		 try{  
			// endpoint以杭州为例，其它region请按实际情况填写
			 String endpoint = "http://oss-cn-beijing.aliyuncs.com";
			 // 云账号AccessKey有所有API访问权限，建议遵循阿里云安全最佳实践，创建并使用RAM子账号进行API访问或日常运维，请登录 https://ram.console.aliyun.com 创建
			 String accessKeyId = "LTAIdK3YAoN99HnE";
			 String accessKeySecret = "YyTBRMZLNVat8rMJuGKWhFxfZnrNBe";
			 // 创建OSSClient实例
			 OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
			// 列举bucket
			 List<Bucket> buckets = ossClient.listBuckets();
			 for (Bucket bucket : buckets) {
			     System.out.println(" - " + bucket.getName());
			 }
			 // 使用访问OSS
			 // 关闭client
			 ossClient.shutdown();
          }catch(Exception e){  
        	  logException("AliPayInterface", "notify", e.toString(),"支付宝回调",e);
          } 
	}  
	
	*//**
	 * 
	 * @param request
	 * @param response
	 *//*
	@RequestMapping(value = "/uploadFile")   
	@ResponseBody 
	public String uploadFile(HttpServletRequest request,HttpServletResponse response){  
		 String url = "http://jingxuanyouhui.oss-cn-beijing.aliyuncs.com/";
		 try{  
			// endpoint以杭州为例，其它region请按实际情况填写http://jingxuanyouhui.oss-cn-beijing.aliyuncs.com/108108.png?Expires=1515991573&OSSAccessKeyId=TMP.AQG31ov-nUrCBgmVgZjWqlxDZdQCyhHO-NTj20j191-1He3XaatvHudirFhCADAtAhRa1aXqNpi_NjTCsXkte7pZ_0OoqAIVANsB8XZ3u3jXJxI4ai3ZOoOOQp2p&Signature=ol8Hkn0OfItmWq8uzJTvkGEztJk%3D
			 String endpoint = "http://oss-cn-beijing.aliyuncs.com";
			 // 云账号AccessKey有所有API访问权限，建议遵循阿里云安全最佳实践，创建并使用RAM子账号进行API访问或日常运维，请登录 https://ram.console.aliyun.com 创建
			 String accessKeyId = "LTAIdK3YAoN99HnE";
			 String accessKeySecret = "YyTBRMZLNVat8rMJuGKWhFxfZnrNBe";
			 // 创建OSSClient实例
			 OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
			 
			 // 使用访问OSS
			// 上传文件流
			 InputStream inputStream = new FileInputStream("C://Users/Administrator/Desktop/ftp/108108.png");
			 
			 String fileName = "108108.png";
			 
			 ossClient.putObject("jingxuanyouhui", fileName, inputStream);
			 // 关闭client
			 ossClient.shutdown();
			 
			 url+=fileName;
          }catch(Exception e){  
        	  logException("AliPayInterface", "notify", e.toString(),"支付宝回调",e);
          } 
		 return url;
	} 
	
*/}